home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmScaleMode
- Caption = "ScaleMode Display"
- ClientHeight = 3885
- ClientLeft = 405
- ClientTop = 1515
- ClientWidth = 4905
- Height = 4290
- Left = 345
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 3885
- ScaleWidth = 4905
- Top = 1170
- Width = 5025
- Begin PictureBox picDraw
- DragIcon = SCALEMOD.FRX:0000
- Height = 1935
- Left = 960
- ScaleHeight = 1905
- ScaleWidth = 2865
- TabIndex = 2
- Top = 720
- Width = 2895
- End
- Begin PictureBox picXaxis
- Height = 255
- Left = 0
- ScaleHeight = 225
- ScaleWidth = 4665
- TabIndex = 1
- Top = 3600
- Width = 4695
- End
- Begin PictureBox picYAxis
- Height = 3615
- Left = 4680
- ScaleHeight = 3585
- ScaleWidth = 225
- TabIndex = 0
- Top = 0
- Width = 255
- End
- Const DM_COPYPEN = 1
- Const DM_NOTXORPEN = 10
- Dim oldCursorX As Single
- Dim oldCursorY As Single
- Dim bTracking As Integer
- Dim Anchor(1) As Single
- Dim bDrag As Integer
- Dim bFirst As Integer
- Sub DrawCursorLocation (Source As Control, X As Single, Y As Single, OldRedraw As Integer, NewRedraw As Integer)
- Dim fcolor As Long
- Dim ii As Integer
- Dim sParam As String
- Dim oldDrawMode As Integer
- Dim oldDrawWidth As Integer
- Dim location As Single
- If True Then
- 'Redraw the X-Axis Cursor Marker
- oldDrawMode = picXaxis.DrawMode
- oldDrawWidth = picXaxis.DrawWidth
- picXaxis.DrawMode = DM_NOTXORPEN 'Not XOR
- picXaxis.DrawWidth = 2
- 'Redraw the old mark
- If OldRedraw = True Then
- location = picXaxis.ScaleWidth * (oldCursorX - Source.ScaleLeft) / Source.ScaleWidth - picXaxis.ScaleLeft
- picXaxis.Line (location, 0)-(location, picXaxis.ScaleHeight)
- End If
- 'Draw the new mark
- If NewRedraw = True Then
- location = picXaxis.ScaleWidth * (X - Source.ScaleLeft) / Source.ScaleWidth + picXaxis.ScaleLeft
- picXaxis.Line (location, 0)-(location, picXaxis.ScaleHeight)
- End If
- 'Store the old Cursor locations and reset the Draw Properties
- oldCursorX = X
- picXaxis.DrawMode = oldDrawMode
- picXaxis.DrawWidth = oldDrawWidth
- 'Redraw the Y-Axis Cursor Marker
- oldDrawMode = picXaxis.DrawMode
- oldDrawWidth = picXaxis.DrawWidth
- 'Set DrawMode to NOTXORPEN
- picYaxis.DrawMode = DM_NOTXORPEN 'Not XOR
- picYaxis.DrawWidth = 2
- 'Redraw the old mark
- If OldRedraw = True Then
- location = picYaxis.ScaleHeight * (oldCursorY - Source.ScaleTop) / Source.ScaleHeight - picYaxis.ScaleTop
- picYaxis.Line (0, location)-(picYaxis.ScaleWidth, location)
- End If
- If NewRedraw = True Then
- 'Draw the new mark
- location = picYaxis.ScaleHeight * (Y - Source.ScaleTop) / Source.ScaleHeight + picYaxis.ScaleTop
- picYaxis.Line (0, location)-(picYaxis.ScaleWidth, location)
- End If
- 'Store the old Cursor locations and reset the Draw Properties
- oldCursorY = Y
- picYaxis.DrawMode = oldDrawMode
- picYaxis.DrawWidth = oldDrawWidth
- Else
- ii = SetTextAlign(Source.hDC, TA_BOTTOM)
- fcolor = Source.ForeColor
- Source.ForeColor = Source.BackColor
- Source.CurrentX = oldCursorX
- Source.CurrentY = oldCursorY
- Source.Print Tag
- Source.ForeColor = fcolor
- Source.CurrentX = X
- Source.CurrentY = Y
- oldCursorX = X
- oldCursorY = Y
- sParam = "(" + LTrim$(RTrim$(Str$(Int(X)))) + "," + LTrim$(RTrim$(Str$(Int(Y)))) + ")"
- Source.Print sParam
- Source.Tag = sParam
- End If
- End Sub
- Sub DrawXRuler (Source As Control, Ruler As Control)
- Const MAJORINC = 10
- Const MINORINC = 4
- Dim ii As Integer
- Dim jj As Integer
- Dim numstr As String
- Dim ScaleInterval As Single
- Dim ScaleValue As Single
- Dim MajorInt As Integer
- Dim MinorInt As Integer
- 'Initialize Ruler scale values
- picXaxis.ScaleMode = 0 'User-defined
- picXaxis.ScaleWidth = 1000
- picXaxis.ScaleHeight = 100
- MajorInt = Ruler.ScaleWidth / MAJORINC
- MinorInt = MajorInt / MINORINC
- ScaleValue = Source.ScaleLeft
- ScaleInterval = Source.ScaleWidth / MAJORINC
- Ruler.Cls
- start = Int(Ruler.ScaleLeft)
- finish = Int(Ruler.ScaleLeft + Ruler.ScaleWidth)
- For ii = start To finish Step MajorInt
- numstr = LTrim$(RTrim$(Str$(Int(ScaleValue))))
- Ruler.Line (ii, 0)-(ii, Ruler.ScaleHeight / 6)
- Ruler.CurrentX = ii - Ruler.TextHeight(numstr) / 2
- Ruler.CurrentY = Ruler.ScaleHeight / 6
- Ruler.Print numstr
- For jj = 1 To MINORINC
- Ruler.Line (ii + MinorInt * jj, 0)-(ii + MinorInt * jj, Ruler.ScaleHeight / 8)
- Next jj
- ScaleValue = ScaleValue + ScaleInterval
- Next ii
- If bFirst Then
- oldDrawMode = picXaxis.DrawMode
- oldDrawWidth = picXaxis.DrawWidth
- 'Set DrawMode to NOTXORPEN
- picXaxis.DrawMode = DM_NOTXORPEN 'Not XOR
- picXaxis.DrawWidth = 2
- location = picXaxis.ScaleWidth * (oldCursorX - ScaleLeft) / ScaleWidth + picXaxis.ScaleLeft
- picXaxis.Line (location, 0)-(location, picXaxis.ScaleHeight)
- picXaxis.DrawMode = oldDrawMode
- picXaxis.DrawWidth = oldDrawWidth
- End If
- End Sub
- Sub DrawYRuler (Source As Control, Ruler As Control)
- Const MAJORINC = 10
- Const MINORINC = 4
- Dim ii As Integer
- Dim jj As Integer
- Dim numstr As String
- Dim ScaleInterval As Single
- Dim ScaleValue As Single
- Dim MajorInt As Integer
- Dim MinorInt As Integer
- picYaxis.ScaleMode = 0 'User-defined
- picYaxis.ScaleWidth = 100
- picYaxis.ScaleHeight = 1000
- MajorInt = Ruler.ScaleHeight / MAJORINC
- MinorInt = MajorInt / MINORINC
- ScaleValue = Source.ScaleTop
- ScaleInterval = Source.ScaleHeight / MAJORINC
- Ruler.Cls
- For ii = Int(Ruler.ScaleTop) To Int(Ruler.ScaleTop + Ruler.ScaleHeight) Step MajorInt
- numstr = LTrim$(RTrim$(Str$(Int(ScaleValue))))
- Ruler.Line (0, ii)-(Ruler.ScaleWidth / 6, ii)
- Ruler.CurrentX = Ruler.ScaleWidth / 6
- Ruler.CurrentY = ii - Ruler.TextHeight(numstr) / 2
- Ruler.Print numstr
- For jj = 1 To MINORINC
- Ruler.Line (0, ii + MinorInt * jj)-(Ruler.ScaleWidth / 8, ii + MinorInt * jj)
- Next jj
- ScaleValue = ScaleValue + ScaleInterval
- Next ii
- If bFirst Then
- oldDrawMode = picXaxis.DrawMode
- oldDrawWidth = picXaxis.DrawWidth
- 'Set DrawMode to NOTXORPEN
- picYaxis.DrawMode = 10 'Not XOR
- picYaxis.DrawWidth = 2
- location = picYaxis.ScaleHeight * (oldCursorY - ScaleTop) / ScaleHeight + picYaxis.ScaleTop
- picYaxis.Line (0, location)-(picYaxis.ScaleWidth, location)
- picYaxis.DrawMode = oldDrawMode
- picYaxis.DrawWidth = oldDrawWidth
- End If
- End Sub
- Sub Form_Load ()
- 'Initialize Ruler Locations
- picYaxis.Width = 455
- picXaxis.Height = 255
- picDraw.Width = frmScaleMode.Width - picYaxis.Width
- picDraw.Height = frmScaleMode.Height - picXaxis.Height
- 'Initialize Ruler scale values
- picXaxis.ScaleMode = 0 'User-defined
- picXaxis.ScaleWidth = 1000
- picXaxis.ScaleHeight = 100
- picYaxis.ScaleMode = 0 'User-defined
- picYaxis.ScaleWidth = 100
- picYaxis.ScaleHeight = 1000
- 'Initialize Ruler fonts
- picXaxis.FontName = "Arial"
- picXaxis.FontSize = 6
- picYaxis.FontName = "Arial"
- picYaxis.FontSize = 6
- oldCursorX = 0
- oldCursorY = 0
- bTracking = False
- bFirst = False
- Form2.Show MODELESS
- End Sub
- Sub Form_Resize ()
- 'Resize and rescale drawing control
- picDraw.Move ScaleLeft, ScaleTop, ScaleWidth - picYaxis.Width, ScaleHeight - picXaxis.Height
- If Form2.optScaleMode(0).Value = True Then
- picDraw.Scale (Form2.txtScale(0), Form2.txtScale(1))-(Form2.txtScale(2), Form2.txtScale(3))
- End If
- 'Resize rulers
- picXaxis.Move ScaleLeft, ScaleHeight - picXaxis.Height, picDraw.Width, picXaxis.Height
- picYaxis.Move ScaleWidth - picYaxis.Width, ScaleTop, picYaxis.Width, picDraw.Height
- End Sub
- Sub Form_Unload (Cancel As Integer)
- Unload Form2
- End
- End Sub
- Sub picDraw_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
- bTracking = True
- Anchor(0) = X
- Anchor(1) = Y
- picDraw.DrawMode = 10
- picDraw.Line (Anchor(0), Anchor(1))-(Anchor(0), Anchor(1)), , B
- End Sub
- Sub picDraw_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
- Dim rtn As Integer
-
- 'If tracking, erase the old rectangle and draw the new one.
- If bTracking Then
- picDraw.Line (Anchor(0), Anchor(1))-(oldCursorX, oldCursorY), , B
- picDraw.Line (Anchor(0), Anchor(1))-(X, Y), , B
- Else
- 'If not tracking, check to see if the mouse has
- 'left the picDraw window. If so, erase the cursor
- 'location marks on the X and Y axis scales and
- 'release capture of the mouse back to the system.
- If X < picDraw.ScaleLeft Or X > picDraw.ScaleLeft + picDraw.ScaleWidth Or Y < picDraw.ScaleTop Or Y > picDraw.ScaleTop + picDraw.ScaleHeight Then
- DrawCursorLocation picDraw, X, Y, True, False
- ReleaseCapture
- bFirst = False
- Exit Sub
- End If
- End If
- 'Draw the current cursor location on the X and Y axis.
- DrawCursorLocation picDraw, X, Y, bFirst, True
- 'If bFirst is False, it means we are entering the
- 'picDraw window. Set capture on the mouse so as to
- 'detect when it leaves the window and set bFirst to True.
- If Not bFirst Then
- rtn = SetCapture(picDraw.hWnd)
- bFirst = True
- End If
- End Sub
- Sub picDraw_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
- 'MouseUp automatically releases capture of the mouse.
- 'For this reason, we must SetCapture again on the MouseUp event
- 'in order to detect when the mouse leaves the picDraw window.
- If bTracking Then
- rtn = SetCapture(picDraw.hWnd)
- bTracking = False
- End If
- End Sub
- Sub picXaxis_Paint ()
- DrawXRuler picDraw, picXaxis
- End Sub
- Sub picYAxis_Paint ()
- DrawYRuler picDraw, picYaxis
- End Sub
-